package com.guanyong.admin.controllers.page;

import com.guanyong.model.MessageModel;
import com.guanyong.model.RoleModel;
import com.guanyong.services.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by mxk on 2017/6/7.
 */
@Controller
@RequestMapping("/page/role")
public class RolePage extends baseController {

    @Autowired
    RoleService roleService;

    @RequestMapping({"/list"})
    String roleList(HttpServletRequest request) {

        return  "/role/list";
    }


    @RequestMapping({"/roleadd"})
    String roleAdd(HttpServletRequest request) {
        return  "/role/roleadd";
    }

    @RequestMapping({"/roleupdate"})
    String roleUpdate(Model model, HttpServletRequest request) {
        String fid=request.getParameter("fid");
        RoleModel roleModel =roleService.GetRoleById(Integer.parseInt(fid));
        if (roleModel!=null){
            model.addAttribute("rolemodel",roleModel);
            return "/role/roleupdate";
        }
        else{
            return "errorPage/500";
        }

    }
}
